// pages/pay/pay.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    address: {},
    cartChecked: [],
    totalpirce: 0,
    totalnum: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let cartChecked = wx.getStorageSync("cartChecked");
    let address = wx.getStorageSync("address");
    console.log(address)
    //  商品总价格、总数量
    let totalpirce = 0;
    let totalnum = 0;
    cartChecked.forEach(v => {
      if (v.checked) {
        totalpirce += v.num * v.goods_price
        totalnum += v.num
      }
    })
    this.setData({
      cartChecked,
      address,
      totalpirce,
      totalnum
    })
  },
  pay(){
    let token = wx.getStorageSync('token');
    if(!token){
      wx.redirectTo({
        url: '/pages/impower/impower'
      })
    }
  }
})